package com.payment.ktb.view;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.flyco.animation.Attention.Tada;
import com.flyco.dialog.widget.base.BaseDialog;
import com.payment.ktb.R;
import com.payment.ktb.activity.main1.CashierActivity;
import com.payment.ktb.constants.ConstantsUpdateArgs;
import com.payment.ktb.utils.ActivityUtils;
import com.payment.ktb.utils.ToastUtils;
import com.payment.ktb.utils.UpdateAPKUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

public class UpdateDialog extends BaseDialog<UpdateDialog> {

    @BindView(R.id.ll_updateversion_cancel)
    LinearLayout ll_updateversion_cancel;
    @BindView(R.id.ll_updateversion_update)
    LinearLayout ll_updateversion_update;
    @BindView(R.id.tv_updateversion_title)
    TextView tv_updateversion_title;
    @BindView(R.id.tv_updateversion_msg)
    TextView tv_updateversion_msg;

    public UpdateDialog(Context context) {
        super(context);
    }

    @Override
    public View onCreateView() {
        //widthScale(0.85f);
        showAnim(new Tada());


        // dismissAnim(this, new ZoomOutExit());
        View inflate = View.inflate(mContext, R.layout.dialog_main1_updateversion, null);
        ButterKnife.bind(this, inflate);
//        inflate.setBackgroundDrawable(
//                CornerUtils.cornerDrawable(Color.parseColor("#ffffff"), dp2px(5)));

        return inflate;
    }

    @Override
    public void setUiBeforShow() {
        tv_updateversion_msg.setText(ConstantsUpdateArgs.updateMsg);
        tv_updateversion_title.setText(ConstantsUpdateArgs.updateTitle);

        ll_updateversion_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
                if (ConstantsUpdateArgs.updateFlg.equals("0")){
                    ConstantsUpdateArgs.isUpd = "0";
                }else {
                    ActivityUtils.removeAllActivity();
                }
            }
        });



        ll_updateversion_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
               UpdateAPKUtils.getInstance(mContext,ConstantsUpdateArgs.downloadUrl).downloadApk();
            }
        });
    }


}
